<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>公司门头模版工具</title>
    <link href="../css/all.min.css" rel="stylesheet">
    <script src="../js/html2canvas.min.js"></script>
    <style>
        :root {
            --primary-color: #3f51b5;
            --secondary-color: #5c6bc0;
            --accent-color: #ff9800;
            --light-bg: #f8f9fa;
            --dark-text: #333;
            --light-text: #666;
        }
        
        body {
            background-color: #fff;
            font-family: 'Noto Sans SC', sans-serif;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            color: var(--dark-text);
            position: relative;
        }
        
        .main-container {
            width: 100%;
            max-width: 800px;
            padding: 30px;
            background-color: white;
            border-radius: 12px;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
            margin-bottom: 30px;
        }
        
        .input-group {
            margin-bottom: 25px;
        }
        
        label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
            color: var(--dark-text);
        }
        
        input[type="text"], select {
            width: 100%;
            padding: 12px 15px;
            border: 1px solid #ddd;
            border-radius: 8px;
            font-size: 16px;
            transition: all 0.3s ease;
            box-sizing: border-box;
        }
        
        input[type="text"]:focus, select:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(63, 81, 181, 0.1);
        }
        
        .controls {
            display: flex;
            gap: 15px;
            margin-bottom: 20px;
        }
        
        .control-group {
            flex: 1;
        }
        
        .preview-container {
            margin-top: 40px;
            padding: 30px;
            background-color: #f5f7ff;
            border-radius: 10px;
            border: 1px dashed var(--secondary-color);
            text-align: center;
            position: relative;
        }
        
        .preview-label {
            position: absolute;
            top: -12px;
            left: 20px;
            background: white;
            padding: 0 10px;
            color: var(--primary-color);
            font-weight: 500;
            font-size: 0.9rem;
        }
        
        .main-text {
            font-size: 3.5rem;
            color: var(--primary-color);
            font-family: 'Playfair Display', serif;
            margin: 0;
            line-height: 1.2;
        }
        
        .sub-text {
            font-size: 1.2rem;
            color: var(--secondary-color);
            margin-top: 15px;
            letter-spacing: 1px;
            font-weight: 500;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .sub-text::before,
        .sub-text::after {
            content: '';
            flex: 1;
            height: 1px;
            background-color: var(--secondary-color);
            margin: 0 10px;
        }
        
        .download-btn {
            position: fixed;
            right: 30px;
            top: 50%;
            transform: translateY(-50%);
            background-color: var(--primary-color);
            color: white;
            border: none;
            padding: 12px 20px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 16px;
            font-weight: 500;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            gap: 8px;
            box-shadow: 0 4px 12px rgba(63, 81, 181, 0.2);
            z-index: 100;
        }
        
        .download-btn:hover {
            background-color: var(--secondary-color);
            transform: translateY(-50%) scale(1.05);
        }
        
        .download-btn:active {
            transform: translateY(-50%) scale(0.98);
        }
        
        .style-options {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 15px;
            margin-bottom: 20px;
        }
        
        .style-option {
            border: 2px solid #eee;
            border-radius: 8px;
            padding: 15px;
            cursor: pointer;
            transition: all 0.3s ease;
            text-align: center;
        }
        
        .style-option:hover {
            border-color: var(--primary-color);
        }
        
        .style-option.active {
            border-color: var(--primary-color);
            background-color: rgba(63, 81, 181, 0.05);
        }
        
        .style-sample {
            font-size: 1.5rem;
            margin-bottom: 5px;
        }
        
        .style-name {
            font-size: 0.9rem;
            color: var(--light-text);
        }
        
        @media (max-width: 768px) {
            .main-container {
                padding: 20px;
            }
            
            .controls {
                flex-direction: column;
            }
            
            .style-options {
                grid-template-columns: 1fr;
            }
            
            .main-text {
                font-size: 2.5rem;
            }
            
            .sub-text {
                font-size: 1rem;
            }
            
            .download-btn {
                position: static;
                transform: none;
                margin-top: 20px;
                width: 100%;
                justify-content: center;
            }
        }
    </style>
</head>
<body>
    <div class="main-container">
        <div class="input-group">
            <label for="inputText">公司名称/标语</label>
            <input type="text" id="inputText" placeholder="请输入公司名称或标语" oninput="updatePreview()">
        </div>
        
        <div class="input-group">
            <label for="subText">副标题/拼音</label>
            <input type="text" id="subText" placeholder="请输入副标题或拼音" oninput="updatePreview()">
        </div>
        
        <div class="controls">
            <div class="control-group">
                <label for="mainColor">主文字颜色</label>
                <input type="color" id="mainColor" value="#3f51b5" oninput="updatePreview()">
            </div>
            <div class="control-group">
                <label for="subColor">副文字颜色</label>
                <input type="color" id="subColor" value="#5c6bc0" oninput="updatePreview()">
            </div>
            <div class="control-group">
                <label for="fontSize">主文字大小</label>
                <select id="fontSize" onchange="updatePreview()">
                    <option value="2.5rem">小</option>
                    <option value="3.5rem" selected>中</option>
                    <option value="4.5rem">大</option>
                </select>
            </div>
        </div>
        
        <div class="style-options">
            <div class="style-option active" onclick="changeStyle('classic')">
                <div class="style-sample" style="font-family: 'Playfair Display', serif;">Aa</div>
                <div class="style-name">经典</div>
            </div>
            <div class="style-option" onclick="changeStyle('modern')">
                <div class="style-sample" style="font-family: 'Arial', sans-serif; font-weight: bold;">Aa</div>
                <div class="style-name">现代</div>
            </div>
            <div class="style-option" onclick="changeStyle('elegant')">
                <div class="style-sample" style="font-family: 'Times New Roman', serif;">Aa</div>
                <div class="style-name">优雅</div>
            </div>
        </div>
        
        <div class="preview-container">
            <div class="preview-label">预览</div>
            <p id="previewMainText" class="main-text">匠心独运，硕望宿归</p>
            <p id="previewSubText" class="sub-text">JIANGXINDUYUN - SHUOWANGSUGUI</p>
        </div>
    </div>
    
    <button class="download-btn" onclick="downloadAsImage()">
        <i class="fas fa-download"></i>
    </button>
    
    <script>
        function updatePreview() {
            const mainText = document.getElementById('inputText').value || '匠心独运，硕望宿归';
            const subText = document.getElementById('subText').value || 'JIANGXINDUYUN - SHUOWANGSUGUI';
            const mainColor = document.getElementById('mainColor').value;
            const subColor = document.getElementById('subColor').value;
            const fontSize = document.getElementById('fontSize').value;
            
            const previewMain = document.getElementById('previewMainText');
            const previewSub = document.getElementById('previewSubText');
            
            previewMain.textContent = mainText;
            previewSub.textContent = subText;
            
            previewMain.style.color = mainColor;
            previewSub.style.color = subColor;
            previewMain.style.fontSize = fontSize;
        }
        
        function changeStyle(style) {
            const previewMain = document.getElementById('previewMainText');
            const options = document.querySelectorAll('.style-option');
            
            options.forEach(opt => opt.classList.remove('active'));
            event.currentTarget.classList.add('active');
            
            switch(style) {
                case 'classic':
                    previewMain.style.fontFamily = "'Playfair Display', serif";
                    previewMain.style.fontWeight = "normal";
                    break;
                case 'modern':
                    previewMain.style.fontFamily = "'Arial', sans-serif";
                    previewMain.style.fontWeight = "bold";
                    break;
                case 'elegant':
                    previewMain.style.fontFamily = "'Times New Roman', serif";
                    previewMain.style.fontWeight = "normal";
                    break;
            }
        }
        
        function downloadAsImage() {
            const previewContainer = document.querySelector('.preview-container');
            
            // 临时隐藏预览标签
            const previewLabel = document.querySelector('.preview-label');
            const originalDisplay = previewLabel.style.display;
            previewLabel.style.display = 'none';
            
            // 增加容器内边距以获得更好的截图效果
            const originalPadding = previewContainer.style.padding;
            previewContainer.style.padding = '40px';
            
            html2canvas(previewContainer, {
                scale: 2, // 提高分辨率
                backgroundColor: '#f5f7ff',
                logging: false,
                useCORS: true
            }).then(canvas => {
                // 恢复原始样式
                previewLabel.style.display = originalDisplay;
                previewContainer.style.padding = originalPadding;
                
                // 创建下载链接
                const link = document.createElement('a');
                link.download = '公司门头设计.png';
                link.href = canvas.toDataURL('image/png');
                link.click();
            });
        }
        
        // 初始化预览
        updatePreview();
    </script>
</body>
</html>
    